package pl.elka.simulator.core.configurationCommand.impl;

import java.util.List;

import pl.elka.simulator.core.GravityPoint;
import pl.elka.simulator.core.Position;
import pl.elka.simulator.core.configurationCommand.ConfigurationCommandType;
import pl.elka.simulator.core.configurationCommand.ICommandParam;
import pl.elka.simulator.core.configurationCommand.IConfigurationCommand;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToConfiguration;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToGravityPointConfiguration;

public class AddGravityAttractionPointConfigurationCommand implements IConfigurationCommand{

	private ICommandParam param;
	
	@Override
	public IConfigurationCommand newInstance() {		
		return new AddGravityAttractionPointConfigurationCommand();
	}

	@Override
	public void setParam(ICommandParam param) {
		this.param = param;
	}

	@Override
	public ICommandParam getParam() {
		return param;
	}

	@Override
	public ConfigurationCommandType getType() {
		return ConfigurationCommandType.AddGravityAttractionPointConfigurationCommand;		
	}

	@Override
	public void execute(IAbleToConfiguration able) {
		IAbleToGravityPointConfiguration na = (IAbleToGravityPointConfiguration) able;
		
		Position position = CommandUtils.getPosition(this);
		List<GravityPoint> points = na.getGravityPoints();
		points.add(new GravityPoint(position));
		na.setGravityPoints(points);
	}

}
